[SPARK-20164][SQL] AnalysisException not tolerant of null query plan.#17486
[SPARK-20164][SQL] AnalysisException not tolerant of null query plan.#17486kunalkhamar wants to merge 4 commits intoapache:masterfrom
Conversation
|
|
||
| override def getMessage: String = { | ||
| val planAnnotation = plan.map(p => s";\n$p").getOrElse("") | ||
| val planAnnotation = if (plan == null) "" else plan.map(p => s";\n$p").getOrElse("") |
There was a problem hiding this comment.
Nit:
val planAnnotation = Option(plan).map(p => s";\n$p").getOrElse("")|
We should pass |
|
@gatorsmile Looks like its happening because |
|
Test build #75403 has finished for PR 17486 at commit
|
|
Test build #75407 has finished for PR 17486 at commit
|
|
Test build #75404 has finished for PR 17486 at commit
|
|
|
||
| override def getMessage: String = { | ||
| val planAnnotation = plan.map(p => s";\n$p").getOrElse("") | ||
| val planAnnotation = Option(plan).map(p => s";\n$p").getOrElse("") |
There was a problem hiding this comment.
Sorry, my fault. We need another flatten.
val planAnnotation = Option(plan).flatten.map(p => s";\n$p").getOrElse("")There was a problem hiding this comment.
Right, updated.
|
Test build #75415 has finished for PR 17486 at commit
|
|
LGTM It sounds like the support of the default value in Scala is weird. I did some searches. Scala omits the default value. Another alternative is to define auxiliary constructor function to explicitly set the default value. |
|
LGTM A variable marked with Quoted from Chapter 25 of Programming in Scala, First Edition: http://www.artima.com/pins1ed/annotations.html
|
|
@kunalkhamar Could you summarize the issue and post it in https://github.com/databricks/scala-style-guide? Thanks! |
The query plan in an `AnalysisException` may be `null` when an `AnalysisException` object is serialized and then deserialized, since `plan` is marked `transient`. Or when someone throws an `AnalysisException` with a null query plan (which should not happen). `def getMessage` is not tolerant of this and throws a `NullPointerException`, leading to loss of information about the original exception. The fix is to add a `null` check in `getMessage`. - Unit test Author: Kunal Khamar <kkhamar@outlook.com> Closes #17486 from kunalkhamar/spark-20164. (cherry picked from commit 254877c) Signed-off-by: Xiao Li <gatorsmile@gmail.com>
|
Thanks! Merging to master and 2.1. |
|
@gatorsmile Verified the behaviour using this, it makes Not sure what to add and where in the scala-style-guide? |
What changes were proposed in this pull request?
The query plan in an
AnalysisExceptionmay benullwhen anAnalysisExceptionobject is serialized and then deserialized, sinceplanis marked@transient. Or when someone throws anAnalysisExceptionwith a null query plan (which should not happen).def getMessageis not tolerant of this and throws aNullPointerException, leading to loss of information about the original exception.The fix is to add a
nullcheck ingetMessage.How was this patch tested?